//
//  XWMainTableVC.m
//  文件下载的断点续传
//
//  Created by Xie Wei on 2019/7/11.
//  Copyright © 2019 谢伟. All rights reserved.
//

#import "XWMainTableVC.h"
#import "ViewController.h"
#import "ViewControllerOne.h"

@interface XWMainTableVC ()

@property (nonatomic, strong) NSMutableArray *dataArrM;

@end

@implementation XWMainTableVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"断点续传的实现方式";
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"UITableViewCell"];
}

#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArrM.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath];
    cell.textLabel.text = self.dataArrM[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        ViewController *vc = (ViewController *)[sb instantiateViewControllerWithIdentifier:@"ViewController"];
        [self.navigationController pushViewController:vc animated:YES];
    } else {
        UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        ViewControllerOne *vc = (ViewControllerOne *)[sb instantiateViewControllerWithIdentifier:@"ViewControllerOne"];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (NSMutableArray *)dataArrM {
    if (_dataArrM == nil) {
        _dataArrM = [[NSMutableArray alloc] initWithArray:@[@"通过流实现断点续传", @"通过句柄实现断点续传"]];
    }
    return _dataArrM;
}

@end
